/* viewer.module.css */

/* 顶部信息栏样式 */
.appContainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5));
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  backdrop-filter: blur(5px);
}

.element1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.element1 img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  object-fit: cover;
}

.element1 span {
  font-size: 18px;
  font-weight: bold;
}

.element1 p {
  font-size: 12px;
  margin: 0;
  opacity: 0.8;
}

.element2 {
  flex: 1;
}

.element2 button {
  background-color: rgba(255, 0, 80, 0.7);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 5px 15px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.element2 button:hover {
  background-color: rgba(255, 0, 80, 1);
  transform: scale(1.05);
}

.element3 {
  display: flex;
  align-items: center;
  gap: 5px;
}

.element3 img {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  object-fit: cover;
}

.closeButton {
  margin-left: 15px;
  font-size: 24px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.closeButton:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* 观众页面主容器 */
.viewerPage {
  position: relative;
  height: 100vh;
  width: 100%;
  background-color: #000;
  overflow: hidden;
}

.mobilePage {
  /* 移动设备特定样式 */
  touch-action: manipulation; /* 优化触摸操作 */
  -webkit-overflow-scrolling: touch; /* 在iOS上提供平滑滚动 */
}

.broadcasterContainer {
  position: relative;
  height: 100vh;
  width: 100%;
  padding-top: 60px; /* 为顶部信息栏留出空间 */
}

.webcamContainer {
  position: relative;
  height: calc(100% - 120px);
  width: 100%;
  overflow: hidden;
}

.webcamContainer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 弹幕容器样式 */
.danmakuContainer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.danmaku {
  position: absolute;
  right: -300px; /* 初始位置在屏幕右侧外 */
  white-space: nowrap;
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  padding: 5px 10px;
  border-radius: 20px;
  background-color: rgba(0, 0, 0, 0.3);
  animation: danmakuMove 8s linear forwards;
  pointer-events: none;
}

@keyframes danmakuMove {
  from {
    right: -300px;
  }
  to {
    right: 100%;
  }
}

/* 礼物动画样式 */
.giftAnimation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: giftAppear 3s ease-in-out;
  z-index: 10;
  text-align: center;
}

.giftAnimation span {
  font-size: 100px;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
}

@keyframes giftAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
}

/* 互动控件区域 */
.controlsContainer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  padding: 15px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
  z-index: 10;
}

.mobileControls {
  padding: 10px;
  flex-wrap: wrap;
  gap: 5px;
}

.messageInput {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 20px;
  color: white;
  padding: 10px 15px;
  margin-right: 10px;
  font-size: 14px;
}

.messageInput::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.sendButton {
  background-color: #ff0050;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sendButton:hover {
  background-color: #e0004c;
  transform: scale(1.05);
}

.giftButton {
  background-color: #ffcc00;
  color: #333;
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  margin-left: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.giftButton:hover {
  background-color: #ffd700;
  transform: scale(1.05);
}

/* 礼物列表样式 */
.giftListContainer {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  border-radius: 10px;
  padding: 15px;
  display: flex;
  gap: 15px;
  animation: slideUp 0.3s ease-in-out;
}

.giftItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.giftItem:hover {
  transform: scale(1.1);
}

.giftIcon {
  font-size: 30px;
  margin-bottom: 5px;
}

.giftName {
  color: white;
  font-size: 12px;
}

.giftPrice {
  color: #ffcc00;
  font-size: 12px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* 设备类型指示器 */
.deviceIndicator {
  position: absolute;
  top: 120px;
  right: 20px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 网络状态指示器样式 */
.networkIndicator {
  position: absolute;
  top: 70px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 5;
}

/* 延迟控制器样式 */
.delayController {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 15px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 10;
  width: 250px;
  backdrop-filter: blur(5px);
}

.delaySlider {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  border-radius: 5px;
  cursor: pointer;
}

.delaySlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ff3366;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delaySlider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #ff5588;
}

.networkIndicator.excellent {
  background-color: rgba(76, 175, 80, 0.7);
}

.networkIndicator.good {
  background-color: rgba(255, 193, 7, 0.7);
}

.networkIndicator.poor {
  background-color: rgba(244, 67, 54, 0.7);
}

/* 连接状态指示器 */
.connectionIndicator {
  position: absolute;
  top: 220px;
  right: 20px;
  background-color: rgba(244, 67, 54, 0.7);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.connectionIndicator.connected {
  background-color: rgba(76, 175, 80, 0.7);
}

/* 低质量视频样式 */
.lowQualityVideo {
  filter: brightness(1.1) contrast(0.9);
}

/* 媒体查询适配不同设备 */
@media (max-width: 768px) {
  .deviceIndicator,
  .networkIndicator,
  .qualityIndicator,
  .connectionIndicator {
    padding: 5px 10px;
    font-size: 12px;
    right: 10px;
  }
  
  .deviceIndicator {
    top: 80px;
  }
  
  .networkIndicator {
    top: 120px;
  }
  
  .connectionIndicator {
    top: 160px;
  }
  
  .qualityIndicator {
    top: 200px;
  }
  
  .messageInput {
    font-size: 12px;
    padding: 8px 12px;
  }
  
  .sendButton,
  .giftButton {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .giftListContainer {
    padding: 10px;
    gap: 10px;
  }
  
  .giftIcon {
    font-size: 24px;
  }
}

/* 更小屏幕设备的适配 */
@media (max-width: 480px) {
  .deviceIndicator,
  .networkIndicator,
  .qualityIndicator,
  .connectionIndicator {
    padding: 4px 8px;
    font-size: 10px;
    right: 5px;
  }
  
  .messageInput {
    padding: 6px 10px;
  }
  
  .sendButton,
  .giftButton {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* 确保在横屏模式下也能正常显示 */
@media (orientation: landscape) and (max-height: 500px) {
  .controlsContainer {
    padding: 8px;
  }
  
  .deviceIndicator {
    top: 70px;
  }
  
  .networkIndicator {
    top: 110px;
  }
  
  .connectionIndicator {
    top: 150px;
  }
  
  .qualityIndicator {
    top: 190px;
  }
}